<template>
  <div class='open'>
    <Form :formData="formData" :formParam="formParam" ></Form>
    <Btn class="margintop40" :buttonData="buttonData" ></Btn>
    <p style="display:none">{{getData}}</p>
  </div>
</template>
<script>
import Form from '../../../common/form'
import Btn from '../../../common/button.vue'
export default {
  props:["data"],
  components: {Form,Btn},
  name: "",
  data() {
    return {
      imgs:{
        info:require('../../../../assets/img/hpmepage/regiment/open.png')
      },
      formData:[
        {
          title:{
            show:true,
            img:require("../../../../assets/img/hpmepage/renew/detail.png"),
            label:"基本信息"
          },
          children:[
            {type:"select",label:"所在地区",key:"address",array:[],readonly:true},
            {type:"input",label:"姓名",key:"name",readonly:true},
            {type:"input",label:"联系方式",key:"phone",readonly:true}
          ],
        }
      ],
      formParam:{
        address:"",
        name:"",
        phone:"",
      },

      buttonData:[
        {
          label:"立即开团",
          click:this.save
        }
      ]
    };
  },
  computed:{
    getData(){
      var address=[]
      this.data.forEach(ele => {
        if(!address.includes(ele.place))address.push(ele.place)
      });
      this.formData[0].children[0].array=address
      this.formParam.address=address[0]
      this.formParam.name=sessionStorage.getItem("userName")
      this.formParam.phone=sessionStorage.getItem("userPhone")
    }
  },
  methods: {
    save(){
      var params={
        id:sessionStorage.getItem("detailId"),
        userId:sessionStorage.getItem("userId"),
        address:this.formParam.address
      }
      var that=this
      _g.apiPost("collage/regiment.do",_g.assign(this.formParam,params)).then(res=>{
        this.$store.state.dialogs.join.content="请在我的订单中查看"
        this.$store.state.dialogs.join.OK=function(){
          that.$router.push("/member/myorder")
        }
        this.$store.state.dialogs.join.show=true
        this.$store.state.dialogs.join.title=res.msg
      })
      console.log("click---立即开团")
    }
  },
  created() {}
};
</script>
<style lang="scss" scoped>
.open {

  .margintop40{
    margin: 40px 30px;
  }
}
</style>
